package com.woniuxy.rms.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.rms.advice.LogPoint;
import com.woniuxy.rms.dto.OrderDTO;
import com.woniuxy.rms.pojo.Goods;
import com.woniuxy.rms.service.DealService;
import com.woniuxy.rms.util.DataResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * Auther: ChenGang  <br/>
 * Date: 2020/3/28 0028:下午 12:30  <br/>
 * Description:交易管理控制层,管理所有的预约和订单
 */
@Controller
@RequestMapping("/deal")
public class DealController {

    @Autowired
    DealService dealService;

    /**
     * Description : 商品订单列表分页查询  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 下午 12:38 [Administrator]);
     * @param currentPage 当前页
     * @param pageSize 页大小
     * @param status 订单状态
     * @return com.woniuxy.rms.util.DataResult
    */
    @GetMapping("/goodsOrderList")
    @ResponseBody
    @LogPoint("查询商品订单")
    public DataResult dealGoodsList(@RequestParam(defaultValue = "1",required = false,name = "page") Integer currentPage,
                                    @RequestParam(defaultValue = "10",required = false,name = "limit") Integer pageSize,
                                    @RequestParam(required = false) Integer status){
        List<OrderDTO> orderDTOS = dealService.findGoodsByPage(currentPage,pageSize,status);
        PageInfo info = new PageInfo(orderDTOS);
        return DataResult.success(info);
    }
    /**
     * Description : 商品订单状态  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 下午 2:31 [Administrator]);
     * @param ids
     * @param status
     * @return com.woniuxy.rms.util.DataResult
    */
    @PutMapping("/checkGoodsOrder")
    @ResponseBody
    @LogPoint("改变商品订单状态")
    public DataResult checkGoodsOrder(String ids,Integer status){
        return dealService.checkGoodsOrder(ids,status);
    }
    /**
     * Description : 服务订单列表分页查询  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 下午 12:38 [Administrator]);
     * @param currentPage 当前页
     * @param pageSize 页大小
     * @param payStatus 订单状态
     * @return com.woniuxy.rms.util.DataResult
    */
    @GetMapping("/goodsServerList")
    @ResponseBody
    @LogPoint("查询服务订单")
    public DataResult dealServerList(@RequestParam(defaultValue = "1",required = false,name = "page") Integer currentPage,
                                    @RequestParam(defaultValue = "10",required = false,name = "limit") Integer pageSize,
                                    @RequestParam(required = false) Integer payStatus){
        List<OrderDTO> orderDTOS = dealService.findServerByPage(currentPage,pageSize,payStatus);
        PageInfo info = new PageInfo(orderDTOS);
        return DataResult.success(info);
    }
    /**
     * Description : 服务订单状态  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 下午 2:31 [Administrator]);
     * @param ids
     * @param payStatus
     * @return com.woniuxy.rms.util.DataResult
    */
    @PutMapping("/checkServerOrder")
    @ResponseBody
    @LogPoint("改变服务订单状态")
    public DataResult checkServerOrder(String ids,Integer payStatus){
        return dealService.checkServerOrder(ids,payStatus);
    }

}